package net.zjitc.homework;

public class TriangularMatrix {
   private  int[] array;

   public TriangularMatrix(){
      
   }
   /**
    * 
    * */
   public void compress(int[][] arr){
       int length=(arr.length+1)*arr.length/2;
       array=new int[length];
       int k=0;
       for (int i = 0; i < arr.length; i++) {
           for (int j = 0; j <= i; j++) {
              array[k]=arr[i][j];
              k++;
           }
       }
   }
 public int values(int i,int j){
       if (j>i){
           return 0;
       }
       else {
           int a=(i+1)*i+j;
           return array[a];
       }
 }
}
